package edu.biola.matthew;

import java.util.Scanner;

public class DateTest {

    public static void main(String[] args) {


		boolean inMenu = true;    // while the user is using the program this var is set to true and the menu keeps looping.
		// when the user wants to quit, it is set to false and the loop ends.
		char keyPressed = '\0';    // This var stores which menu selection the user picks.

		while (inMenu) {
			System.out.println("");
			System.out.println("");
			System.out.println("");

			System.out.println("****************************************************");
			System.out.println("**  MENU:(press a character to select an option)  **");
			System.out.println("****************************************************" );
			System.out.println("");


			System.out.println("Q. [QUIT]     Quit." );
			System.out.println("C. [Constructor]	Test the default constructor and more" );
			System.out.println("S. [Set ]     Test the other constructor and the SetDate method,"  );
			System.out.println("R. [Read date]  Test the ReadDate, ComparedTo, and ComparedCentury methods" );
			System.out.println("");


			System.out.println("A. [Advance date]    Test the AdvanceDate method" );
			System.out.println("B. [Back date]  Test the BackDate method" );
			System.out.println("T. [Test]   Test further how well the date move back");
			System.out.println("****************************************************"  );

			System.out.print("Your choice is: ");

			Scanner s = new Scanner(System.in);
			try {

				keyPressed = (char) System.in.read();
			} catch (Exception e) {

			}




			//Two DateType objects to be tested
			DateType taxDay = new DateType();    //Declared and constructued by the default constructor

			DateType groundHogDay = new DateType (2, 12, 2001); //Declared and constructued by the second constructor


			//Some  more objects and variables for testing in the code below
			DateType AdvancedDate = new DateType();
			DateType BackDate = new DateType();
			int numDays;
			int ddd;
			char chr;


			DateType x;

			switch (keyPressed) {
				case 'Q':
				case 'q'://Quit
					System.out.println("[QUIT]:");

					inMenu = false;
					break;

				case 'C':
				case 'c':
					System.out.println("");
					System.out.println("");

					System.out.println("******************************************************************");
					System.out.println( "***   Test 1: test taxDay, a DateType object declared in the main function," );
					System.out.println( "***   to see how the defualt constructor, and YearIs(), MonthIs() ");
					System.out.println("***   DayIs() and the PrintDate() methods work on taxDay");
					System.out.println("******************************************************************");



					System.out.println("taxDay is initialized by the default constructor method:");
					System.out.println("taxDay: year is " + taxDay.getYear()) ;
					System.out.println("taxDay: day is " +taxDay.getDay());
					System.out.println("taxDay: month is " + taxDay.getMonth());
					System.out.println("");



					taxDay.readDate();

					System.out.println(" PrintDate method prints the contents of taxDay as:");
					taxDay.printDate();



					break;

				case 'S':
				case 's':
					System.out.println("");
					System.out.println("");
					System.out.println("******************************************************************" );
					System.out.println("***   Test 2: test the second constructor,  SetDate() and");
					System.out.println( "***  and the PrintDate() method ***");
					System.out.println("******************************************************************");
					System.out.println("groundHogDay is initialized by the second constructor:");

					System.out.println("groundHogDay(2,12,2001)");
					System.out.println("The result is ");

					groundHogDay.printDate();

					groundHogDay.setDate(8, 8, 2005);
					System.out.println("");
					System.out.println("groundHogDay is reset now: groundHogDay.SetDate(8,8,2005)");
					System.out.println("The result is");
					groundHogDay.printDate();
					break;

				case 'R':
				case 'r':// 3. Append new lines of code to the end

					System.out.println("");
					System.out.println("");
					System.out.println( "******************************************************************");
					System.out.println( "***   Test 3: test ReadDate(), ComparedTo( ) and ");
					System.out.println("***   ComparedCentury methods ");
					System.out.println("******************************************************************");


					System.out.println("");
					System.out.println("Get a new groundHogDay");
					groundHogDay.readDate();
					System.out.println("");
					System.out.println( "Got the groundHogDay as");

					groundHogDay.printDate();

					System.out.println("");
					System.out.println("Get a new taxDay");

					taxDay.readDate();
					System.out.println("");
					System.out.println( "Got the taxDay as");

					taxDay.printDate();

			 /* cout << taxDay.ComparedTo(groundHogDay) << endl;*/

					//ComparedTo is being called on taxDay instance
					//groundHogDay is the parameter

					if (taxDay.comparedTo(groundHogDay) == DateType.LESS)
						System.out.println("taxDay is less than groundHogDay");

					else if (taxDay.comparedTo(groundHogDay) == DateType.EQUAL)
						System.out.println("taxDay is equal to groundHogDay");

					else
						System.out.println("taxDay is greater than groundHogDay" );


					//ComparedTo is being called on groundHogDay instance
					//taxDay is the parameter

					if (groundHogDay.comparedTo(taxDay) == DateType.LESS)
						System.out.println("groundHogDay is less than taxDay" );

					else if (groundHogDay.comparedTo(taxDay) == DateType.EQUAL)
						System.out.println("groundHogDay is equal to taxDay" );

					else
						System.out.println("groundHogDay is greater than taxDay" );


					//ComparedCentury is being called on groundHogDay instance
					//taxDay is the parameter
					if (groundHogDay.comparedCentury(taxDay) == DateType.LESS)
						System.out.println("groundHogDay is in an earlier century"  );

					else if (groundHogDay.comparedCentury(taxDay) == DateType.EQUAL)
						System.out.println( "groundHogDay and taxday are in the same century"  );

					else
						System.out.println( "groundHogDay is in a later century"  );


					//ComparedCentury is being called on taxDay instance
					//groundHogDay is the parameter
					if (taxDay.comparedCentury(groundHogDay) == DateType.LESS)
						System.out.println( "taxDay is in an earlier century" );

					else if (taxDay.comparedCentury(groundHogDay) == DateType.EQUAL)
						System.out.println(  "taxDay and groundHogDay are in the same century" );

					else
						System.out.println(   "taxDay is in a later century" );


					break;

				case 'A':
				case 'a':// 4.

					System.out.println("");
					System.out.println("");

					System.out.println("******************************************************************");
					System.out.println("*** Test 4: test the AdvanceDays( )  method ");
					System.out.println("******************************************************************");


					//cout << endl << "Set the initial date:" << endl;
					//AdvancedDate.ReadDate();
					//AdvancedDate.PrintDate();
					//cout << endl << "Advance the date:" << endl;

					//cout << "How many days to advence into the future?";
					//cin  >> numDays;
					//AdvancedDate.AdvanceDays(numDays);
					//cout << "The new date is: ";
					//AdvancedDate.PrintDate();
					break;

				case 'B':
				case 'b':// 5.
					System.out.println("");
					System.out.println("");

					System.out.println("******************************************************************" );
					System.out.println("*** Test 5: test the BackDays( ) method ");
					System.out.println("******************************************************************");



					//cout << endl << "Set the initial date:" << endl;
					//AdvancedDate.ReadDate();
					//AdvancedDate.PrintDate();
					//cout << endl << "Set back the date:" << endl;
					//cout << "How many days to set back into hte past?";
					//cin  >> numDays;
					//AdvancedDate.BackDays(numDays);
					//cout << "The new date is: ";
					//AdvancedDate.PrintDate();
					break;


				case 'T':
				case 't':// 6.

					System.out.println("");
					System.out.println("");

					System.out.println("******************************************************************" );
					System.out.println("*** Test 6: Check the BackDays( ) method 365 times and verify " );
					System.out.println( "*** it can correctly set Feb 14, 2007 back into Feb 14, 2006." );
					System.out.println("******************************************************************");



					// x.SetDate(2,14,2007);
					// x.PrintDate();
					// cout << endl << endl;

					// ddd = 0;

					// //Back to Jan, 14, 2007
					// for (int i=0; i<31; i++)
					// {
					//x.BackDays(1);
					//x.PrintDate();
					//cout << endl << endl;
					// }
					// ddd+= 31;
					// cout <<"Enter c to continue:";
					// cin >> chr;

					////Back to Dec, 14, 2006
					// for (int i=0; i<31; i++)
					// {
					//x.BackDays(1);
					//x.PrintDate();
					//cout << endl << endl;
					// }
					// ddd+= 31;
					// cout <<"Enter c to continue:";
					// cin >> chr;


					// //Back to Nov, 14, 2006
					// for (int i=0; i<30; i++)
					// {
					//x.BackDays(1);
					//x.PrintDate();
					//cout << endl << endl;
					// }
					// ddd+= 30;
					// cout <<"Enter c to continue:";
					// cin >> chr;


					// //Back to Oct, 14, 2006
					// for (int i=0; i<31; i++)
					// {
					//x.BackDays(1);
					//x.PrintDate();
					//cout << endl << endl;
					// }
					// ddd+= 31;
					// cout <<"Enter c to continue:";
					// cin >> chr;


					// //Back to Sept, 14, 2006
					// for (int i=0; i<30; i++)
					// {
					//x.BackDays(1);
					//x.PrintDate();
					//cout << endl << endl;
					// }
					// ddd+= 30;
					// cout <<"Enter c to continue:";
					// cin >> chr;


					// //Back to Aug, 14, 2006
					// for (int i=0; i<31; i++)
					// {
					//x.BackDays(1);
					//x.PrintDate();
					//cout << endl << endl;
					// }
					// ddd+= 31;
					// cout <<"Enter c to continue:";
					// cin >> chr;


					// //Back to July, 14, 2006
					// for (int i=0; i<31; i++)
					// {
					//x.BackDays(1);
					//x.PrintDate();
					//cout << endl << endl;
					// }
					// ddd+= 31;
					// cout <<"Enter c to continue:";
					// cin >> chr;


					// //Back to June, 14, 2006
					// for (int i=0; i<30; i++)
					// {
					//x.BackDays(1);
					//x.PrintDate();
					//cout << endl << endl;
					// }
					// ddd+= 30;
					// cout <<"Enter c to continue:";
					// cin >> chr;


					// //Back to May, 14, 2006
					// for (int i=0; i<31; i++)
					// {
					//x.BackDays(1);
					//x.PrintDate();
					//cout << endl << endl;
					// }
					// ddd+= 31;
					// cout <<"Enter c to continue:";
					// cin >> chr;


					// //Back to April, 14, 2006
					// for (int i=0; i<30; i++)
					// {
					//x.BackDays(1);
					//x.PrintDate();
					//cout << endl << endl;
					// }
					// ddd+= 30;
					// cout <<"Enter c to continue:";
					// cin >> chr;


					//
					// //Back to March, 14, 2006
					// for (int i=0; i<31; i++)
					// {
					//x.BackDays(1);
					//x.PrintDate();
					//cout << endl << endl;
					// }
					// ddd+= 31;
					// cout <<"Enter c to continue:";
					// cin >> chr;


					////Back to Feb, 14, 2006
					// for (int i=0; i<28; i++)
					// {
					//x.BackDays(1);
					//x.PrintDate();
					//cout << endl << endl;
					// }
					// ddd+= 28;


					// cout << ddd << " days back from Feb 14, 2007 is :"  << endl;
					// x.PrintDate();
					break;

				default:
					System.out.println("[?? UNKNOWN COMMAND]:");

					// Unrecognized key, do nothing
					break;
			}


		}
	}
}
